<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Map数据类型</title>
</head>
<body>
  
</body>

<script type="text/javascript">

  // Map类型是键值对的有序列表，键和值是任意类型
  let map = new Map()

  // map中添加键值
  map.set('name', 'zhangsan')
  map.set('age', 20)
  console.log(map)

  // 根据key获取value
  console.log(map.get('name'));

  // 判读map中是否有key
  console.log(map.has('name'));

  // 删除map中key
  map.delete('age')
  console.log(map);

  // 清空map
  map.clear()

  console.log(map);

  let map1 = new Map([
    ['a', 1],
    ['b', 2]
  ])
  console.log(map1);
  console.log(map1.get('a'));



</script>
</html>